#include <iostream>
#include <string>
#include <vector>
#include <stdexcept>

using std::vector;
using std::string;
using std::cout;
using std::cin;
using std::endl;


int t5_1()
{

	int sum = 0, val = 1;

	while (val <= 10)
		sum += val, ++val;

	cout << "sum: " << sum;
	return 0;
}

int i;
int t5_8()
{
	/*
	 * 默认初始化,
	 */

	int j;
	string s1;
	int k, h;
	cout << "s1: " << s1 << " " << "i:" << i << " "
			<< "j: " << j << endl;
	cout << "k: " << k << " h: " << h << endl;
	return 0;
}

int t5_9()
{
	string s1, sum;
	while (getline(cin, s1))
	{
		if ("0" == s1)
			break;
		sum += s1;
	}

	int num_y{0};
	for (auto c: sum)
	{
		switch(c)
		{
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
		case 'A':
		case 'E':
		case 'I':
		case 'O':
		case 'U':
			num_y += 1;
			break;
		}
	}

	cout << "元音字符个数： " << num_y << endl;
	return 0;
}

int t5_13()
{
	int i = 1;
	const unsigned int swt = 1;
	switch (i)
	{
	// case 只能是整型常量表达式
	case swt:
		cout << "i: " << i << endl;
	}
	return 0;
}

int t5_14()
{

	vector<int> v;
	int i;

	while (cin >> i)
	{
		if (0 == i)
			break;
		v.push_back(i);
	}

	auto beg = v.begin();
	while (beg != v.end() && *beg >= 0)
		++beg;
	if (beg == v.end())
		cout << "所有的都是正数" << endl;
	return 0;
}

int testTry()
{

	double a, b;
	cout << "PLease enter two nums: " << endl;
	cin >> a >> b;

	if (0 == b)
	{
		try
		{
			throw std::runtime_error("0");
			double result = a / b;
		}
		catch (std::runtime_error err)
		{
			std::cerr << "divided by zero" << endl;
		}
	}
	cout << "a / b = " << a / b << endl;
	return 0;
}


int main05()
{
//	t5_1();
//	t5_8();
//	t5_9();
//	t5_13();
//	t5_14();
	testTry();
	return 0;
}
